<?xml version="1.0" encoding="utf-8"?>
<Content xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:blueonionsoftware-com:bloget:runtime:data">
  <text>
		&lt;p&gt;The .NET runtime has so many features it is difficult to keep track. Just the other night, I need to write a byte[] to a file. I started out with something like this:&lt;/p&gt;
		&lt;div style="FONT-SIZE: 9pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;
				&lt;p style="MARGIN: 0px"&gt;
						&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;FileStream&lt;/span&gt; stream = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt;&lt;span style="COLOR: teal"&gt;FileStream&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"myfile"&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;FileMode&lt;/span&gt;.CreateNew))&lt;/p&gt;
				&lt;p style="MARGIN: 0px"&gt;{&lt;/p&gt;
				&lt;p style="MARGIN: 0px"&gt;    stream.Write(buffer, 0, buffer.Length);&lt;/p&gt;
				&lt;p style="MARGIN: 0px"&gt;}&lt;/p&gt;
		&lt;/div&gt;
		&lt;p&gt;Not bad but it is a little tedious. Then I discovered quite by accident that .NET 2.0 added helper methods to the System.File class including &lt;strong&gt;System.File.WriteAllBytes&lt;/strong&gt;.&lt;/p&gt;
		&lt;p&gt;Other "helper" methods include &lt;strong&gt;ReadAllBytes&lt;/strong&gt;, &lt;strong&gt;ReadAllLines&lt;/strong&gt;, &lt;strong&gt;ReadAllText&lt;/strong&gt;, &lt;strong&gt;WriteAllLines&lt;/strong&gt;, &lt;strong&gt;WriteAllText&lt;/strong&gt; and &lt;strong&gt;AppendAllText&lt;/strong&gt;. These methods are not hard to write as evidenced above, but they sure are handy none-the-less.&lt;/p&gt;
		&lt;p&gt;So now the example above becomes:&lt;/p&gt;
		&lt;p style="FONT-SIZE: 9pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: courier new"&gt;
				&lt;span style="COLOR: teal"&gt;File&lt;/span&gt;.WriteAllBytes(&lt;span style="COLOR: maroon"&gt;"myfile"&lt;/span&gt;, buffer);&lt;/p&gt;
		&lt;p style="FONT-SIZE: 9pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: courier new"&gt; &lt;/p&gt;
</text>
  <last_update>2007-07-25T02:56:23.796875Z</last_update>
  <source_title />
  <source_link />
  <comments />
  <references />
  <attachments />
</Content>